using System;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace OracleInternal.NotificationServices
{
	internal class Concurrency
	{
		protected internal long scanTime;

		protected internal int index;

		protected internal int assignedIndex;

		protected internal int scanIndex;

		protected internal bool active;

		protected internal bool listFailed;

		protected internal virtual long ScanTime
		{
			set
			{
				scanTime = value;
			}
		}

		protected internal Concurrency(int myIndex)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.Concurrency, OracleTraceFuncName.ctor);
			}
			index = myIndex;
			scanIndex = 0;
			clear();
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.Concurrency, OracleTraceFuncName.ctor);
			}
		}

		protected internal virtual void assign(Connection connection)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.Concurrency, OracleTraceFuncName.assign);
			}
			try
			{
				assignedIndex = connection.ListIndex;
				active = true;
				connection.ConcurrencyIndex = index;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)270532608, OracleTraceClassName.Concurrency, OracleTraceFuncName.assign, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.Concurrency, OracleTraceFuncName.assign);
				}
			}
		}

		protected internal virtual void connected()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.Concurrency, OracleTraceFuncName.connected);
			}
			listFailed = false;
			scanIndex = assignedIndex;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.Concurrency, OracleTraceFuncName.connected);
			}
		}

		protected internal virtual void clear()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.Concurrency, OracleTraceFuncName.clear);
			}
			assignedIndex = -1;
			active = false;
			listFailed = false;
			scanTime = 0L;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.Concurrency, OracleTraceFuncName.clear);
			}
		}

		protected internal virtual void setListFailed()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.Concurrency, OracleTraceFuncName.setListFailed);
			}
			listFailed = true;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.Concurrency, OracleTraceFuncName.setListFailed);
			}
		}
	}
}
